#include "Queue.h"
#include "Person.h"
#include <iostream>

using  namespace std;

Queue::Queue() {
	//  firstOne = new queueNode();
	//  lastOne = firstOne->next;
	firstOne = lastOne = nullptr;
	size_ = 0;
}

Queue::~Queue() {}

int Queue::getsize()
{
	return size_;
}

bool Queue::empty_()
{
	return (size_ == 0) ? true : false;
}

void Queue::pop()
{
	if (size_ == 1)
	{
		queueNode* temp = firstOne;
		firstOne = firstOne->next;
		lastOne = firstOne;
		delete temp;
		size_--;
	}
	else if (size_ == 0)
	{
		return;
	}
	else
	{
		queueNode* temp = firstOne;
		firstOne = firstOne->next;
		delete temp;
		size_--;
	}

}

void Queue::push(Person* p)
{
	if (size_ == 0)
	{
		firstOne = lastOne = new queueNode(p);
		size_++;
	}
	else
	{
		lastOne->next = new queueNode(p);
		lastOne = lastOne->next;
		size_++;
	}
}

Person* Queue::front_()
{
	return firstOne->chessnode;
}

Person* Queue::back_()
{
	return lastOne->chessnode;
}
